import 'package:flutter_wan_android/entity/structure_nav_entity.dart';
import 'package:flutter_wan_android/entity/article_entity.dart';

structureNavEntityFromJson(StructureNavEntity data, Map<String, dynamic> json) {
	if (json['articles'] != null) {
		data.articles = new List<ArticleEntity>();
		(json['articles'] as List).forEach((v) {
			data.articles.add(new ArticleEntity().fromJson(v));
		});
	}
	if (json['cid'] != null) {
		data.cid = json['cid'] is String
				? int.tryParse(json['cid'])
				: json['cid'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	return data;
}

Map<String, dynamic> structureNavEntityToJson(StructureNavEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	if (entity.articles != null) {
		data['articles'] =  entity.articles.map((v) => v.toJson()).toList();
	}
	data['cid'] = entity.cid;
	data['name'] = entity.name;
	return data;
}